home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / lfs / lfsDescMap.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  19.4 KB  |  709 lines

  1. /* 
  2.  * lfsDescMap.c --
  3.  *
  4.  *    Routines providing access fields to the LFS descriptor map.
  5.  *    This modules responsible for cacheing, writing, and checkpointing the
  6.  *    LFS descriptor map for a file system.
  7.  *
  8.  * Copyright 1989 Regents of the University of California
  9.  * Permission to use, copy, modify, and distribute this
  10.  * software and its documentation for any purpose and without
  11.  * fee is hereby granted, provided that the above copyright
  12.  * notice appear in all copies.  The University of California
  13.  * makes no representations about the suitability of this
  14.  * software for any purpose.  It is provided "as is" without
  15.  * express or implied warranty.
  16.  */
  17.  
  18. #ifndef lint
  19. static char rcsid[] = "$Header: /cdrom/src/kernel/Cvsroot/kernel/lfs/lfsDescMap.c,v 1.8 91/08/22 13:19:35 mendel Exp $ SPRITE (Berkeley)";
  20. #endif /* not lint */
  21.  
  22. #include <sprite.h>
  23. #include <lfs.h>
  24. #include <lfsInt.h>
  25. #include <lfsDescMap.h>
  26. #include <lfsDesc.h>
  27. #include <lfsStableMemInt.h>
  28. #include <lfsSeg.h>
  29. #include <fsutil.h>
  30.  
  31.  
  32. /*
  33.  *----------------------------------------------------------------------
  34.  *
  35.  * LfsDescMapGetVersion --
  36.  *
  37.  *    Return the descriptor map truncate version for the specified
  38.  *    file.
  39.  *
  40.  * Results:
  41.  *    SUCCESS if the entry is resident in the descriptor map.
  42.  *    FS_FILE_NOT_FOUND if the file is not allocated.
  43.  *    GEN_INVALID_ARG if the fileNumber is not available in the map.
  44.  *    
  45.  * Side effects:
  46.  *    None.
  47.  *
  48.  *----------------------------------------------------------------------
  49.  */
  50.  
  51. ReturnStatus
  52. LfsDescMapGetVersion(lfsPtr, fileNumber, versionNumPtr)
  53.     Lfs      *lfsPtr;    /* File system of descriptor. */
  54.     int      fileNumber;   /* File number of descriptor. */ 
  55.     unsigned short  *versionNumPtr; /* Area to return version number in.*/
  56. {
  57.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  58.     LfsStableMemEntry smemEntry;
  59.     LfsDescMapEntry   *entryPtr;
  60.     ReturnStatus      status;
  61.  
  62.     status = LfsStableMemFetch(&(mapPtr->stableMem), fileNumber, 0,
  63.         &smemEntry);
  64.     if (status != SUCCESS) {
  65.     return status;
  66.     }
  67.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  68.  
  69.     if (!(entryPtr->flags & LFS_DESC_MAP_ALLOCED)) {
  70.     status = FS_FILE_NOT_FOUND;
  71.     } else { 
  72.     *versionNumPtr = entryPtr->truncVersion;
  73.     }
  74.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, FALSE);
  75.     return status;
  76.  
  77. }
  78.  
  79. /*
  80.  *----------------------------------------------------------------------
  81.  *
  82.  * LfsDescMapIncVersion --
  83.  *
  84.  *    Increment the truncate version number for the specified
  85.  *    file.
  86.  *
  87.  * Results:
  88.  *    SUCCESS if the entry is resident in the descriptor map.
  89.  *    GEN_INVALID_ARG if the fileNumber is not available in the map.
  90.  *    
  91.  * Side effects:
  92.  *    Version number of entry increment.
  93.  *
  94.  *----------------------------------------------------------------------
  95.  */
  96.  
  97. ReturnStatus
  98. LfsDescMapIncVersion(lfsPtr, fileNumber, versionPtr)
  99.     Lfs      *lfsPtr;    /* File system of descriptor. */
  100.     int      fileNumber;   /* File number of descriptor. */ 
  101.     int      *versionPtr;  /* OUT: New truncate version number. */
  102. {
  103.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  104.     LfsDescMapEntry   *entryPtr;
  105.     ReturnStatus      status;
  106.     LfsStableMemEntry    smemEntry;
  107.  
  108.     status = LfsStableMemFetch(&(mapPtr->stableMem), fileNumber, 
  109.             LFS_STABLE_MEM_MAY_DIRTY, &smemEntry);
  110.     if (status != SUCCESS) {
  111.     return status;
  112.     }
  113.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  114.  
  115.     *versionPtr = ++(entryPtr->truncVersion);
  116.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, TRUE);
  117.     return SUCCESS;
  118. }
  119.  
  120. /*
  121.  *----------------------------------------------------------------------
  122.  *
  123.  * LfsDescMapGetDiskAddr --
  124.  *
  125.  *    Return the disk address of the specified descriptor.
  126.  *
  127.  * Results:
  128.  *    SUCCESS if the entry is resident in the descriptor map.
  129.  *    FS_FILE_NOT_FOUND if the file is not allocated.
  130.  *    GEN_INVALID_ARG if the fileNumber is not available in the map.
  131.  *    
  132.  * Side effects:
  133.  *    None.
  134.  *
  135.  *----------------------------------------------------------------------
  136.  */
  137.  
  138. ReturnStatus
  139. LfsDescMapGetDiskAddr(lfsPtr, fileNumber, diskAddrPtr)
  140.     Lfs      *lfsPtr;    /* File system of descriptor. */
  141.     int      fileNumber;   /* File number of descriptor. */ 
  142.     LfsDiskAddr  *diskAddrPtr; /* Current disk address.*/
  143. {
  144.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  145.     LfsDescMapEntry   *entryPtr;
  146.     ReturnStatus      status;
  147.     LfsStableMemEntry    smemEntry;
  148.  
  149.     status = LfsStableMemFetch(&(mapPtr->stableMem), fileNumber, 0,
  150.              &smemEntry);
  151.     if (status != SUCCESS) {
  152.     return status;
  153.     }
  154.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  155.  
  156.     if (!(entryPtr->flags & LFS_DESC_MAP_ALLOCED)) {
  157.     status = FS_FILE_NOT_FOUND;
  158.     }
  159.     *diskAddrPtr = entryPtr->blockAddress;
  160.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, FALSE);
  161.     return status;
  162.  
  163. }
  164.  
  165. /*
  166.  *----------------------------------------------------------------------
  167.  *
  168.  * LfsDescMapSetDiskAddr --
  169.  *
  170.  *    Set the disk address for the specified descriptor.
  171.  *
  172.  * Results:
  173.  *    SUCCESS if the entry is resident in the descriptor map.
  174.  *    FAILURE if the fileNumber is not available in the map.
  175.  *    
  176.  * Side effects:
  177.  *    None.
  178.  *
  179.  *----------------------------------------------------------------------
  180.  */
  181.  
  182. ReturnStatus
  183. LfsDescMapSetDiskAddr(lfsPtr, fileNumber, diskAddr)
  184.     Lfs      *lfsPtr;    /* File system of descriptor. */
  185.     int      fileNumber;   /* File number of descriptor. */ 
  186.     LfsDiskAddr diskAddr; /* New disk address.*/
  187. {
  188.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  189.     LfsDescMapEntry   *entryPtr;
  190.     ReturnStatus    status;
  191.     LfsStableMemEntry    smemEntry;
  192.  
  193.     status = LfsStableMemFetch(&(mapPtr->stableMem), fileNumber, 
  194.                 LFS_STABLE_MEM_MAY_DIRTY, &smemEntry);
  195.     if (status != SUCCESS) {
  196.     return status;
  197.     }
  198.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  199.  
  200.     if (!(entryPtr->flags & LFS_DESC_MAP_ALLOCED)) {
  201.     status = FAILURE;
  202.     } else { 
  203.     if (!LfsIsNullDiskAddr(entryPtr->blockAddress)) { 
  204.         LfsSegUsageFreeBlocks(lfsPtr, sizeof(LfsFileDescriptor), 1, 
  205.                   &entryPtr->blockAddress);
  206.         LFS_STATS_INC(lfsPtr->stats.desc.descMoved);
  207.     }
  208.     entryPtr->blockAddress = diskAddr;
  209.     }
  210.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, (status == SUCCESS));
  211.     return status;
  212.  
  213. }
  214.  
  215. /*
  216.  *----------------------------------------------------------------------
  217.  *
  218.  * LfsDescMapGetAccessTime --
  219.  *
  220.  *    Return the file access time for the specified file number.
  221.  *
  222.  * Results:
  223.  *    SUCCESS if the entry is resident in the descriptor map.
  224.  *    FAILURE if the fileNumber is not available in the map.
  225.  *    
  226.  * Side effects:
  227.  *    None.
  228.  *
  229.  *----------------------------------------------------------------------
  230.  */
  231.  
  232. ReturnStatus
  233. LfsDescMapGetAccessTime(lfsPtr, fileNumber, accessTimePtr)
  234.     Lfs      *lfsPtr;    /* File system of descriptor. */
  235.     int      fileNumber;   /* File number of descriptor. */ 
  236.     int  *accessTimePtr; /* Current access time.*/
  237. {
  238.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  239.     LfsDescMapEntry   *entryPtr;
  240.     ReturnStatus      status;
  241.     LfsStableMemEntry    smemEntry;
  242.  
  243.     status = LfsStableMemFetch(&(mapPtr->stableMem), fileNumber, 0, 
  244.                 &smemEntry);
  245.     if (status != SUCCESS) {
  246.     return status;
  247.     }
  248.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  249.  
  250.     if (!(entryPtr->flags & LFS_DESC_MAP_ALLOCED)) {
  251.     status = FAILURE;
  252.     }
  253.     *accessTimePtr = entryPtr->accessTime;
  254.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, FALSE);
  255.     return status;
  256.  
  257. }
  258.  
  259. /*
  260.  *----------------------------------------------------------------------
  261.  *
  262.  * LfsDescMapSetAccessTime --
  263.  *
  264.  *    Set the file access time for the specified file number.
  265.  *
  266.  * Results:
  267.  *    SUCCESS if the entry is resident in the descriptor map.
  268.  *    FAILURE if the fileNumber is not available in the map.
  269.  *    
  270.  * Side effects:
  271.  *    None.
  272.  *
  273.  *----------------------------------------------------------------------
  274.  */
  275.  
  276. ReturnStatus
  277. LfsDescMapSetAccessTime(lfsPtr, fileNumber, accessTime)
  278.     Lfs      *lfsPtr;    /* File system of descriptor. */
  279.     int      fileNumber;   /* File number of descriptor. */ 
  280.     int  accessTime; /* New current access time.*/
  281. {
  282.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  283.     LfsDescMapEntry   *entryPtr;
  284.     ReturnStatus      status;
  285.     LfsStableMemEntry    smemEntry;
  286.  
  287.     status = LfsStableMemFetch(&(mapPtr->stableMem), fileNumber, 
  288.                 LFS_STABLE_MEM_MAY_DIRTY, &smemEntry);
  289.     if (status != SUCCESS) {
  290.     return status;
  291.     }
  292.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  293.  
  294.     if (!(entryPtr->flags & LFS_DESC_MAP_ALLOCED)) {
  295.     status = FAILURE;
  296.     } else { 
  297.     entryPtr->accessTime = accessTime;
  298.     }
  299.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, (status == SUCCESS));
  300.  
  301.     return status;
  302.  
  303. }
  304.  
  305.  
  306. /*
  307.  *----------------------------------------------------------------------
  308.  *
  309.  * Lfs_GetNewFileNumber --
  310.  *
  311.  *    Allocate an used file number for a newly created file or directory.
  312.  *
  313.  * Results:
  314.  *    An error if could not find a free file descriptor.
  315.  *    SUCCESS if a file number can be allocate.
  316.  *    FAILURE if all available file numbers are taken.
  317.  *    
  318.  * Side effects:
  319.  *    None.
  320.  *
  321.  *----------------------------------------------------------------------
  322.  */
  323.  
  324. ReturnStatus
  325. Lfs_GetNewFileNumber(domainPtr, dirFileNum, fileNumberPtr)
  326.     Fsdm_Domain     *domainPtr;    /* Domain to allocate the file 
  327.                      * descriptor out of. */
  328.     int     dirFileNum;    /* File number of the directory that
  329.              * the file is in.  -1 means that
  330.              * this file descriptor is being
  331.              * allocated for a directory. */
  332.     int    *fileNumberPtr; /* Place to return the file number allocated. */
  333. {
  334.     Lfs    *lfsPtr = LfsFromDomainPtr(domainPtr);
  335.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  336.     register LfsDescMapEntry   *entryPtr;
  337.     register int maxNumDesc, startDesc, i;
  338.     Boolean    found = FALSE;
  339.     ReturnStatus      status;
  340.     static    int dirSeed = 0;
  341.     LfsStableMemEntry    smemEntry;
  342.  
  343.     maxNumDesc = mapPtr->params.maxDesc;
  344.     LFS_STATS_INC(lfsPtr->stats.desc.getNewFileNumber);
  345.     if (dirFileNum == -1) {
  346.     if (dirSeed == 0) {
  347.         dirSeed = Fsutil_TimeInSeconds();
  348.     } 
  349.         /*
  350.          * Search linearly from a random starting descriptor.
  351.          */
  352.         startDesc = ((dirSeed * 1103515245 + 12345) & 0x7fffffff) %
  353.                         maxNumDesc;
  354.     dirSeed++;
  355.     } else {
  356.     startDesc = dirFileNum;
  357.     }
  358.     status = LfsStableMemFetch(&(mapPtr->stableMem), startDesc, 
  359.             LFS_STABLE_MEM_MAY_DIRTY,
  360.             &smemEntry);
  361.     if (status != SUCCESS) {
  362.     return status;
  363.     }
  364.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  365.     i = startDesc;
  366.     do { 
  367.     if (!(entryPtr->flags & LFS_DESC_MAP_ALLOCED)) {
  368.         found = TRUE;
  369.         break;
  370.     }
  371.     LFS_STATS_INC(lfsPtr->stats.desc.scans);
  372.     i++;
  373.         if (i == maxNumDesc) {
  374.         i = 0;
  375.     }
  376.     status = LfsStableMemFetch(&(mapPtr->stableMem), i, 
  377.             (LFS_STABLE_MEM_MAY_DIRTY| 
  378.              LFS_STABLE_MEM_REL_ENTRY), &smemEntry);
  379.     if (status != SUCCESS) {
  380.         return status;
  381.     }
  382.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  383.    } while (i != startDesc);
  384.     if (!found) {    
  385.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, FALSE);
  386.         printf( "Out of file descriptors.\n");
  387.     return FAILURE;
  388.     }
  389.     mapPtr->checkPoint.numAllocDesc++;
  390.     LfsSetNilDiskAddr(&entryPtr->blockAddress);
  391.     entryPtr->flags = LFS_DESC_MAP_ALLOCED;
  392.     *fileNumberPtr = i;
  393.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, TRUE);
  394.     return SUCCESS;
  395. }
  396.  
  397.  
  398. /*
  399.  *----------------------------------------------------------------------
  400.  *
  401.  * Lfs_FreeFileNumber() --
  402.  *
  403.  *    Mark a file number as unused and make it available for re-allocation.
  404.  *
  405.  * Results:
  406.  *    SUCCESS if a file number was not allocated.
  407.  *    FAILURE if all available file numbers are taken.
  408.  *    
  409.  * Side effects:
  410.  *    Descriptor map entry is modified for the file.
  411.  *
  412.  *----------------------------------------------------------------------
  413.  */
  414.  
  415. ReturnStatus
  416. Lfs_FreeFileNumber(domainPtr, fileNumber)
  417.     Fsdm_Domain     *domainPtr;    /* Domain of the file descriptor. */
  418.     int      fileNumber;   /* File number to free. */
  419. {
  420.     Lfs    *lfsPtr = LfsFromDomainPtr(domainPtr);
  421.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  422.     LfsDescMapEntry   *entryPtr;
  423.     ReturnStatus      status;
  424.     LfsStableMemEntry    smemEntry;
  425.  
  426.     LFS_STATS_INC(lfsPtr->stats.desc.free);
  427.  
  428.     status = LfsStableMemFetch(&(mapPtr->stableMem), fileNumber, 
  429.             LFS_STABLE_MEM_MAY_DIRTY, &smemEntry);
  430.     if (status != SUCCESS) {
  431.     return status;
  432.     }
  433.     entryPtr = (LfsDescMapEntry *) LfsStableMemEntryAddr(&smemEntry);
  434.  
  435.     if (!(entryPtr->flags & LFS_DESC_MAP_ALLOCED)) {
  436.     status = FAILURE;
  437.     } else { 
  438.     entryPtr->flags &= ~LFS_DESC_MAP_ALLOCED;
  439.     LfsSegUsageFreeBlocks(lfsPtr, sizeof(LfsFileDescriptor), 1, 
  440.               &entryPtr->blockAddress);
  441.     LfsSetNilDiskAddr(&entryPtr->blockAddress);
  442.     mapPtr->checkPoint.numAllocDesc--;
  443.     }
  444.     LfsStableMemRelease(&(mapPtr->stableMem), &smemEntry, (status == SUCCESS));
  445.     return status;
  446. }
  447.  
  448.  
  449.  
  450. extern ReturnStatus LfsDescMapAttach _ARGS_((Lfs *lfsPtr, int checkPointSize, 
  451.         char *checkPointPtr));
  452. extern Boolean LfsDescMapCheckpoint _ARGS_((LfsSeg *segPtr, int flags, 
  453.         char *checkPointPtr, int *checkPointSizePtr, 
  454.         ClientData *clientDataPtr));
  455. extern Boolean LfsDescMapLayout _ARGS_((LfsSeg *segPtr, int flags, 
  456.         ClientData *clientDataPtr));
  457. extern void LfsDescMapWriteDone _ARGS_((LfsSeg *segPtr, int flags,
  458.         ClientData *clientDataPtr));
  459. extern Boolean LfsDescMapClean _ARGS_((LfsSeg *segPtr, int *sizePtr, 
  460.         int *numCacheBlocksPtr, ClientData *clientDataPtr));
  461. extern ReturnStatus LfsDescMapDetach _ARGS_((Lfs *lfsPtr));
  462.  
  463. static LfsSegIoInterface descMapIoInterface = 
  464.     { LfsDescMapAttach, LfsDescMapLayout, LfsDescMapClean,
  465.       LfsDescMapCheckpoint, LfsDescMapWriteDone, LfsDescMapDetach, 0};
  466.  
  467.  
  468. /*
  469.  *----------------------------------------------------------------------
  470.  *
  471.  * LfsDescMapInit --
  472.  *
  473.  *    Initialize the the descriptor map data structures.  
  474.  *
  475.  * Results:
  476.  *    None
  477.  *    
  478.  * Side effects:
  479.  *
  480.  *----------------------------------------------------------------------
  481.  */
  482.  
  483. void
  484. LfsDescMapInit()
  485. {
  486.     LfsSegIoRegister(LFS_DESC_MAP_MOD,&descMapIoInterface);
  487. }
  488.  
  489.  
  490. /*
  491.  *----------------------------------------------------------------------
  492.  *
  493.  * DescMapAttach --
  494.  *
  495.  *    Attach routine for the descriptor map. Creates and initializes the
  496.  *    map for this file system.
  497.  *
  498.  * Results:
  499.  *    SUCCESS if attaching is going ok.
  500.  *
  501.  * Side effects:
  502.  *    Many
  503.  *
  504.  *----------------------------------------------------------------------
  505.  */
  506.  
  507. ReturnStatus
  508. LfsDescMapAttach(lfsPtr, checkPointSize, checkPointPtr)
  509.     Lfs   *lfsPtr;         /* File system for attach. */
  510.     int   checkPointSize;    /* Size of checkpoint data. */
  511.     char  *checkPointPtr;     /* Data from last checkpoint before shutdown. */
  512. {
  513.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  514.     LfsDescMapCheckPoint *cp = (LfsDescMapCheckPoint *) checkPointPtr;
  515.     ReturnStatus    status;
  516.     int            size;
  517.  
  518.     /*
  519.      * Allocate and fill in memory data structure for descriptor map.
  520.      */
  521.     mapPtr->params = lfsPtr->superBlock.descMap;
  522.     mapPtr->checkPoint = *cp;
  523.     /*
  524.      * Load the index and buffer using the LfsStableMem routines.
  525.      */
  526.     size = sizeof(LfsDescMapCheckPoint);
  527.     status = LfsStableMemLoad(lfsPtr, &(mapPtr->params.stableMem), 
  528.             checkPointSize - size,
  529.             checkPointPtr + size,
  530.             &(mapPtr->stableMem));
  531.     if (status != SUCCESS) {
  532.     LfsError(lfsPtr, status, "Can't loading descriptor map index\n");
  533.     return status;
  534.     }
  535.  
  536.     return status;
  537. }
  538.  
  539. /*
  540.  *----------------------------------------------------------------------
  541.  *
  542.  * DescMapDetach --
  543.  *
  544.  *    Detach routine for the descriptor map. Destory the
  545.  *    map for this file system.
  546.  *
  547.  * Results:
  548.  *    SUCCESS if attaching is going ok.
  549.  *
  550.  * Side effects:
  551.  *    Many
  552.  *
  553.  *----------------------------------------------------------------------
  554.  */
  555.  
  556. ReturnStatus
  557. LfsDescMapDetach(lfsPtr)
  558.     Lfs   *lfsPtr;         /* File system for attach. */
  559. {
  560.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  561.     return LfsStableMemDestory(lfsPtr, &(mapPtr->stableMem));
  562. }
  563.  
  564. /*
  565.  *----------------------------------------------------------------------
  566.  *
  567.  * DescMapCheckpoint --
  568.  *
  569.  *    Routine to handle checkpointing of the descriptor map data.
  570.  *
  571.  * Results:
  572.  *    TRUE if more data needs to be written, FALSE if this module is
  573.  *    checkpointed.
  574.  *
  575.  * Side effects:
  576.  *    Many
  577.  *
  578.  *----------------------------------------------------------------------
  579.  */
  580.  
  581. Boolean
  582. LfsDescMapCheckpoint(segPtr, flags, checkPointPtr, checkPointSizePtr, 
  583.             clientDataPtr)
  584.     LfsSeg *segPtr;        /* Segment containing data for checkpoint. */
  585.     int       flags;        /* Flags for shutdown */
  586.     char   *checkPointPtr;      /* Buffer to write checkpoint data. */
  587.     int       *checkPointSizePtr;  /* Bytes added to the checkpoint area.*/
  588.     ClientData *clientDataPtr;    
  589. {
  590.     Lfs              *lfsPtr = segPtr->lfsPtr;
  591.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  592.     LfsDescMapCheckPoint *cp = (LfsDescMapCheckPoint *) checkPointPtr;
  593.     int        size, dataSize;
  594.     Boolean    full;
  595.  
  596.     *cp = mapPtr->checkPoint;
  597.     size = sizeof(LfsDescMapCheckPoint);
  598.     dataSize = 0;
  599.     full = LfsStableMemCheckpoint(segPtr, checkPointPtr + size, flags,
  600.             &dataSize, clientDataPtr, &(mapPtr->stableMem));
  601.     if (!full) { 
  602.     (*checkPointSizePtr) = dataSize + size;
  603.     }
  604.     return full;
  605.  
  606. }
  607.  
  608. /*
  609.  *----------------------------------------------------------------------
  610.  *
  611.  * LfsDescMapLayout --
  612.  *
  613.  *    Routine to handle writing of the descriptor map data.
  614.  *
  615.  * Results:
  616.  *    TRUE if more data needs to be written, FALSE if this module is
  617.  *    statisified
  618.  *
  619.  * Side effects:
  620.  *    Many
  621.  *
  622.  *----------------------------------------------------------------------
  623.  */
  624. Boolean
  625. LfsDescMapLayout(segPtr, flags, clientDataPtr)
  626.     LfsSeg *segPtr;        /* Segment to place data blocks in. */
  627.     int    flags;        /* Flags. */
  628.     ClientData    *clientDataPtr;
  629. {
  630.     Lfs              *lfsPtr = segPtr->lfsPtr;
  631.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  632.  
  633.     if ((flags & LFS_CLEANING_LAYOUT) != 0) {
  634.     return FALSE;
  635.     }
  636.     return LfsStableMemLayout(segPtr, flags, clientDataPtr, &(mapPtr->stableMem));
  637. }
  638.  
  639. /*
  640.  *----------------------------------------------------------------------
  641.  *
  642.  * DescWriteDone --
  643.  *
  644.  *    Routine to handle finishing of a checkpoint.
  645.  *
  646.  * Results:
  647.  *    None
  648.  *
  649.  * Side effects:
  650.  *    Many
  651.  *
  652.  *----------------------------------------------------------------------
  653.  */
  654.  
  655. void
  656. LfsDescMapWriteDone(segPtr, flags, clientDataPtr)
  657.     LfsSeg *segPtr;        /* Segment containing data for checkpoint. */
  658.     int       flags;        /* Flags for checkpoint */
  659.     ClientData *clientDataPtr;
  660. {
  661.     Lfs              *lfsPtr = segPtr->lfsPtr;
  662.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  663.  
  664.     LFS_STATS_ADD(lfsPtr->stats.desc.mapBlocksWritten,
  665.         (LfsSegSummaryBytesLeft(segPtr) / sizeof(int)));
  666.  
  667.     LfsStableMemWriteDone(segPtr, flags, clientDataPtr, &(mapPtr->stableMem));
  668.     return;
  669.  
  670. }
  671.  
  672.  
  673. /*
  674.  *----------------------------------------------------------------------
  675.  *
  676.  * DescMapClean --
  677.  *
  678.  *    Routine to handle cleaning of descriptor map data.
  679.  *
  680.  * Results:
  681.  *    TRUE if more data needs to be written, FALSE if this module is
  682.  *    happy for the time being.
  683.  *
  684.  * Side effects:
  685.  *    
  686.  *
  687.  *----------------------------------------------------------------------
  688.  */
  689.  
  690. Boolean
  691. LfsDescMapClean(segPtr, sizePtr, numCacheBlocksPtr, clientDataPtr)
  692.     LfsSeg *segPtr;    /* Segment containing data to clean. */
  693.     int       *sizePtr;        /* Segment to place data blocks in. */
  694.     int *numCacheBlocksPtr;
  695.     ClientData *clientDataPtr;
  696. {
  697.     Lfs              *lfsPtr = segPtr->lfsPtr;
  698.     LfsDescMap          *mapPtr = &(lfsPtr->descMap);
  699.     Boolean full;
  700.  
  701.     full =  LfsStableMemClean(segPtr, sizePtr, numCacheBlocksPtr, 
  702.         clientDataPtr, &(mapPtr->stableMem));
  703.  
  704.     LFS_STATS_ADD(lfsPtr->stats.desc.mapBlockCleaned,
  705.         *sizePtr/mapPtr->stableMem.params.blockSize);
  706.     return full;
  707. }
  708.  
  709.